<template>
	<view class="container">
		<view class="content">
			<view class="title">
				<h3>{{title}}</h3>
			</view>
			<view class="code">
				准考证号:<input class="uni-input" focus type="number" placeholder="请输入准考证号"
				 @input="inputChange" value="" maxlength="11"/>
			</view>
			<button type="primary" size="mini" @click="next">下一步</button>
		</view>
	</view>
	
</template>

<script>
	import {numquery} from '../../apis'
	export default{
		data() {
			return{
				title:'',
				competitionId:0,
				examCode:0,
				groupType:0
			}
		},
		onLoad(option) {
			console.log(option)
			this.groupType=option.groupType;
			this.title = option.title;
			this.competitionId = option.competitionId;
		},
		methods:{
			//判断准考证号是否输入
			next() {
				numquery({
					"competitionId": this.competitionId,
					"phone": this.examCode,
					"groupType":this.groupType
				}).then((res) => {
					let [err, data] = res
					if (data.data.code !== '200') {
						uni.showToast({
							title: '该学生未报名！',
							image: '../../static/gantan.png'
						})
					}else if(this.examCode == ''){
						uni.showToast({
							title: '请输入准考证号！',
							image:"../../static/gantan.png"
						});
					}else{
						// this.examCode = '',
						console.log("跳转开始")
						uni.navigateTo({
		url: '../postgradeList/postgradeList?title='+this.title+'&competitionId='+this.competitionId+'&phone='+this.examCode+'&groupType='+this.groupType
						})
					}
				})
			},
			//获取输入框中的value值
			inputChange(e){
				this.examCode =e.detail.value
				console.log("输入的值为："+e.detail.value)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content{
		padding-top: 50px;
		h3{
			font-size: 16px;
			font-weight: 900;
			margin: 0 auto;
			text-align: center;
			margin-bottom: 20px;
		}
		.code{
			font-size: 16px;
			font-weight: bold;
			margin: 0 auto;
			text-align: center;
			input{
				display: inline-block;
				border: 2px solid #C0C0C0;
				vertical-align: middle;
				margin-left: 3px;
				font-size: 12px;
			}
		}
		button{
			left: 50%;
			transform: translateX(-50%);
			margin-top: 50px;
		}
	}
</style>
